/*
 * @Date: 2023-03-05 14:45:29
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-03-05 15:05:46
 * @FilePath: \A19\backend\src\utils\deleteFile.ts
 */
import fs from 'fs/promises'
import { Folder } from './Folder';
import path from "path";
export default async function(folder:Folder,url:string){
    let resFilePath = path.join('uploads',url)
    console.log((resFilePath));
    let isExisted = await fs.access((resFilePath)).then(() => true).catch(() => false);
    if(isExisted){
        try {
            await fs.unlink(resFilePath)
            console.log("unlinked");
        } catch (error) {
            if(error instanceof Error){
                throw error
            }
        }
    }
}